﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:MiniUML.View.Controls">

    <Style TargetType="{x:Type controls:SingleClickBlock}">

        <Style.Resources>

            <Style x:Key="FocusVisualStyle">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Control}"/>
                    </Setter.Value>
                </Setter>
            </Style>

            <ControlTemplate x:Key="ControlTemplate" TargetType="{x:Type ContentControl}">

                <Grid x:Name="_border" Background="{TemplateBinding Background}">

                    <Rectangle x:Name="_focusRectangle" Stroke="#60000000" StrokeThickness="1" StrokeDashArray="1 2"/>
                    <ContentPresenter x:Name="_contentPresenter" Margin="1"/>

                </Grid>

                <ControlTemplate.Triggers>

                    <Trigger Property="IsKeyboardFocusWithin" Value="False">
                        <Setter Property="Visibility" Value="Hidden" TargetName="_focusRectangle"/>
                        <Setter Property="IsHitTestVisible" Value="False" TargetName="_contentPresenter"/>
                    </Trigger>

                    <Trigger Property="IsKeyboardFocusWithin" Value="False" SourceName="_contentPresenter">
                        <Setter Property="Background" Value="Transparent" TargetName="_border"/>
                    </Trigger>

                </ControlTemplate.Triggers>

            </ControlTemplate>

        </Style.Resources>

        <Setter Property="Template" Value="{StaticResource ControlTemplate}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}"/>
        <Setter Property="Background" Value="White"/>
        
    </Style>

</ResourceDictionary>